<template>
  <div class="bottom-bar">
    <div class="check-content">
      <check-button class="check-button"></check-button>
      <span >全选</span>
    </div>
    <div class="total">
      合计:￥{{totalPrice}}
    </div>

    <div class="count">
      去计算({{checkLength}})
    </div>
  </div>
</template>

<script>
import CheckButton from "./CheckButton";
import {mapGetters} from 'vuex'
export default {
  name: "CartBottomBar",
  components: {
    CheckButton
  },
  computed:{
    ...mapGetters(["cartList"]),
      //钟总价格
    totalPrice(){
      return this.cartList.filter((item) => {
        return item.checked
      }).reduce((previousValue, currentValue) => {
        return currentValue.price*currentValue.count+previousValue
      },0).toFixed(2)
    },
    checkLength(){
        return this.cartList.filter((item) => {
          return item.checked
        }).reduce((previousValue, currentValue) => {
          return previousValue+currentValue.count
        },0)
    }
  }
}
</script>

<style scoped>
.bottom-bar {
  height: 40px;
  display: flex;
  line-height: 40px;
  background-color: #ededed;
}

.check-content {
  width: 100px;
  display: flex;
}


.check-button {
  width: 40px;
  position: relative;
  bottom: 6px;
  left: 10px;
}

.total{
  flex: 1;
}

.count{
  width: 100px;
  background-color: #ff5200;
  text-align: center;
  color: #f2f5f8;
}
</style>